package com.aw.guiguzi.module.manager.msg.presenters

import com.aw.baselib.base.AwCommonPresenter
import com.aw.baselib.net.callback.AwApiCallback
import com.aw.guiguzi.bean.BasePageRspBean
import com.aw.guiguzi.bean.MsgItemBean
import com.aw.guiguzi.module.manager.msg.views.ManagerMsgListView
import com.aw.guiguzi.net.observers.NetObCommon

/**
 * @author : hzw
 */
class ManagerMsgListPresent(private val mView: ManagerMsgListView.View) : AwCommonPresenter(),
    ManagerMsgListView.Presenter {
    override fun getMsgList(pageIndex: Int) {
        addIOSubscription<BasePageRspBean<MsgItemBean>>(
            NetObCommon.getMsgListManager(pageIndex),
            object : AwApiCallback<BasePageRspBean<MsgItemBean>>(mView, true, true) {
                override fun onSuccess(result: BasePageRspBean<MsgItemBean>) {
                    mView.getMsgListSuccess(result.total, result?.list ?: emptyList())
                }

                override fun onFail(code: Int, msg: String) {
                    super.onFail(code, msg)
                    mView.showMsg(msg)
                    mView.getMsgListFail(code, msg)
                }
            })
    }
}